package org.dreamwork.tools.concurrent;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by seth.yang on 2018/12/10
 */
public class Message {
    public int what;
    public Object arg;
    private Map<String, Object> payload = new HashMap<> ();

    public Message () {}

    public Message (int what) { this.what = what; }

    public Message (Object arg) { this.arg = arg; }

    public Message (int what, Object arg) {
        this.what = what;
        this.arg  = arg;
    }

    public<T> void set (String key, T value) {
        payload.put (key, value);
    }

    @SuppressWarnings ("unchecked")
    public<T> T get (String key) {
        return (T) payload.get (key);
    }

    public void remove (String key) {
        payload.remove (key);
    }
}